// 白名单
const whiteList = ['/api/login', '/api/auth', '/api/oauth/redirect']

module.exports = (options, app) => {
  return async (ctx, next) => {
    console.log('whiteList.includes(ctx.path):', whiteList.includes(ctx.path))
    try {
      if (whiteList.includes(ctx.path)) {
        console.log('get参数', JSON.stringify(ctx.query))
        console.log('post参数', JSON.stringify(ctx.request.body))
        await next()
      } else {
        ctx.body = { code: -1, msg: 'fail' }
      }
    } catch (err) {
      ctx.body = {
        code: -1,
        msg: err,
      }
    }
  }
}
